package com.clusterswisdom.horn.api.tmall.action.trade;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.TmallInstance;
import com.taobao.api.request.TradeFullinfoGetRequest;
import com.taobao.api.response.TradeFullinfoGetResponse;

public class PushTradeLogisticsAddressChangedAction implements HornAction{
	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		TradeFullinfoGetResponse response = (TradeFullinfoGetResponse)TmallInstance.getInstance().executeRequest(param, "trade", "tradeFullinfoGet");
		
		JSONObject responseDate = new JSONObject();
		responseDate.put("ttradeId", response.getTrade().getTid());
		responseDate.put("customerDName", response.getTrade().getReceiverName());
		responseDate.put("customerPhone", response.getTrade().getReceiverPhone() == null ? "" : response.getTrade().getReceiverPhone());
		responseDate.put("customerMobile", response.getTrade().getReceiverMobile() == null ? "" : response.getTrade().getReceiverMobile());
		responseDate.put("customerEmail", response.getTrade().getBuyerEmail() == null ? "" : response.getTrade().getBuyerEmail());
		responseDate.put("customerState", response.getTrade().getReceiverState());
		responseDate.put("customerAddress", response.getTrade().getReceiverAddress());
		responseDate.put("customerZip", response.getTrade().getReceiverZip() == null ? "" : response.getTrade().getReceiverZip());
		responseDate.put("customerMemo", response.getTrade().getBuyerMemo() == null ? "" : response.getTrade().getBuyerMemo());

		return new HornResponse(true, responseDate);
	}
}
